<html>
<head><meta charset="utf-8"><title>destructuring grammar conflicts · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html">destructuring grammar conflicts</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="136436107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136436107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136436107">(Oct 24 2018 at 21:01)</a>:</h4>
<p>What piece of the grammar causes this exciting error message?</p>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nc">foo</span><span class="p">;</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Thing</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">foo</span>: <span class="nb">String</span> <span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">example</span><span class="p">(</span><span class="n">t</span>: <span class="nc">Thing</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">Thing</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<div class="codehilite"><pre><span></span>error[E0308]: mismatched types
 --&gt; src/lib.rs:5:17
  |
5 |     let Thing { foo } = t;
  |                 ^^^ expected struct `std::string::String`, found struct `foo`
  |
  = note: expected type `std::string::String`
             found type `foo`
</pre></div>



<a name="136436194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136436194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136436194">(Oct 24 2018 at 21:03)</a>:</h4>
<p>That's a fun error.</p>



<a name="136436272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136436272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136436272">(Oct 24 2018 at 21:04)</a>:</h4>
<p>Right? Like, I'd think it'd prefer an ident over a type, but I'm guessing its a pattern thing.</p>



<a name="136436637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136436637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136436637">(Oct 24 2018 at 21:12)</a>:</h4>
<p>This compiles...</p>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nc">foo</span><span class="p">;</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Thing</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">foo</span>: <span class="nc">foo</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">example</span><span class="p">(</span><span class="n">t</span>: <span class="nc">Thing</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">Thing</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="136436673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136436673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136436673">(Oct 24 2018 at 21:13)</a>:</h4>
<p>but this doesn't</p>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nc">foo</span><span class="p">;</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Thing</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">foo</span>: <span class="nc">foo</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">example</span><span class="p">(</span><span class="n">t</span>: <span class="nc">Thing</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">Thing</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="136438076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438076">(Oct 24 2018 at 21:40)</a>:</h4>
<p>when you name a constant (and <code>struct foo;</code> declares a constant)</p>



<a name="136438078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438078">(Oct 24 2018 at 21:40)</a>:</h4>
<p>you are not producing a binding</p>



<a name="136438081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438081">(Oct 24 2018 at 21:40)</a>:</h4>
<p>you are matching that value</p>



<a name="136438084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438084">(Oct 24 2018 at 21:40)</a>:</h4>
<p><code>let Thing { foo }</code> is of course shorthand for <code>let Thing { foo: foo }</code></p>



<a name="136438093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438093">(Oct 24 2018 at 21:40)</a>:</h4>
<p>so it says "match the value of the field <code>foo</code> with the constant <code>foo</code>"</p>



<a name="136438096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438096">(Oct 24 2018 at 21:40)</a>:</h4>
<p><code>mut foo</code> doesn't make sense, this is not a binding</p>



<a name="136438098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438098">(Oct 24 2018 at 21:40)</a>:</h4>
<p>it's like saying <code>match x { mut None =&gt; .. }</code></p>



<a name="136438116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438116">(Oct 24 2018 at 21:41)</a>:</h4>
<p>As an aside, in Ye Olde Rust of Yore, you had to write a <code>.</code> after constants</p>



<a name="136438138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438138">(Oct 24 2018 at 21:41)</a>:</h4>
<p>e.g., <code>alt foo { Some(x) { value }, None. { other_value } }</code> (in those days, we didn't write <code>=&gt;</code> either, and <code>match</code> was called <code>alt</code>)</p>



<a name="136438142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438142">(Oct 24 2018 at 21:41)</a>:</h4>
<p>also, we walked uphill both ways.</p>



<a name="136438203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438203">(Oct 24 2018 at 21:42)</a>:</h4>
<p>oh I and think that was before the capitalization conventions that made this largely a non-issue</p>



<a name="136438216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438216">(Oct 24 2018 at 21:42)</a>:</h4>
<p><code>alt foo { some(x) { value } none. { other_value } }</code>?</p>



<a name="136438221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438221">(Oct 24 2018 at 21:42)</a>:</h4>
<p>something like that</p>



<a name="136438225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438225">(Oct 24 2018 at 21:42)</a>:</h4>
<p>I remember you would write <code>option::t&lt;t&gt;</code> instead of <code>Option&lt;T&gt;</code> :) (such ocaml)</p>



<a name="136438228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136438228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136438228">(Oct 24 2018 at 21:42)</a>:</h4>
<p>/me stops rambling now</p>



<a name="136479751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479751">(Oct 25 2018 at 14:15)</a>:</h4>
<blockquote>
<p>the capitalization conventions</p>
</blockquote>
<p>I think that's a key thing here. That and the fact that it's a unit struct. If either of those were different, this likely wouldn't pop up in real code.</p>



<a name="136479785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479785">(Oct 25 2018 at 14:15)</a>:</h4>
<p>This is ultimately from Diesel, which generates a bunch of those lower-cased unit structs to represent column names.</p>



<a name="136479790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479790">(Oct 25 2018 at 14:15)</a>:</h4>
<p>I still sometimes wonder if we should have done <code>Some(let x)</code> instead of <code>Some(x)</code></p>



<a name="136479801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479801">(Oct 25 2018 at 14:15)</a>:</h4>
<p>It seemed too verbose but Swift did it and .. it seems fine</p>



<a name="136479808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479808">(Oct 25 2018 at 14:16)</a>:</h4>
<p>And someone had a table with a column called <code>title</code> that they were trying to destructure.</p>



<a name="136479862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479862">(Oct 25 2018 at 14:16)</a>:</h4>
<p>I see</p>



<a name="136479865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479865">(Oct 25 2018 at 14:16)</a>:</h4>
<p><code>Some(let x)</code> certainly has some consistency benefits</p>



<a name="136479884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479884">(Oct 25 2018 at 14:16)</a>:</h4>
<p>water under the bridge now, at least until Rust 2021 :P</p>



<a name="136479897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479897">(Oct 25 2018 at 14:17)</a>:</h4>
<p>we could allow <code>Some(let x)</code> for explicitness and add an autofixable lint for it</p>



<a name="136479898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479898">(Oct 25 2018 at 14:17)</a>:</h4>
<blockquote>
<p>This is ultimately from Diesel, which generates a bunch of those lower-cased unit structs to represent column names.</p>
</blockquote>
<p>I suspect it's a hygiene issue first of all.</p>



<a name="136479900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479900">(Oct 25 2018 at 14:17)</a>:</h4>
<p>no reason for breaking changes</p>



<a name="136479904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136479904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136479904">(Oct 25 2018 at 14:17)</a>:</h4>
<p>true</p>



<a name="136480028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136480028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136480028">(Oct 25 2018 at 14:19)</a>:</h4>
<blockquote>
<p>allow Some(let x) for explicitness</p>
</blockquote>
<p>Rather like <code>dyn Foo</code> in that case.</p>



<a name="136480084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136480084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136480084">(Oct 25 2018 at 14:20)</a>:</h4>
<p>jop</p>



<a name="136480130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136480130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136480130">(Oct 25 2018 at 14:21)</a>:</h4>
<p><code>let MyStruct { let member, let mut other, .. } = s</code></p>



<a name="136483511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136483511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136483511">(Oct 25 2018 at 15:04)</a>:</h4>
<p>this may make <code>let let r#let = "let";</code> a valid syntax <span class="emoji emoji-1f643" title="upside down">:upside_down:</span></p>



<a name="136484250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136484250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136484250">(Oct 25 2018 at 15:13)</a>:</h4>
<p>We already have <code>x @ _</code> for unambiguously making identifier pattern a fresh binding.</p>



<a name="136484324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136484324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136484324">(Oct 25 2018 at 15:14)</a>:</h4>
<p>But it still can't shadow unit structs for other reasons. Ha-ha.</p>



<a name="136484529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136484529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136484529">(Oct 25 2018 at 15:17)</a>:</h4>
<p>(But that's fixable.)</p>



<a name="136488145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/136488145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#136488145">(Oct 25 2018 at 16:04)</a>:</h4>
<blockquote>
<p>We already have <code>x @ _</code> for unambiguously making identifier pattern a fresh binding.</p>
</blockquote>
<p>interesting, I hadn't thought of that :) kind of a hack though</p>



<a name="137073932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/137073932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#137073932">(Nov 02 2018 at 18:37)</a>:</h4>
<p>I was going to suggest that dealing with this particular case wasn't required until I read this...<br>
This indeed will be unlikely to occur on human written code, but it is very likely to happen in macros.</p>
<p>Should I create a ticket to handle this in the same way we handle the following?</p>
<div class="codehilite"><pre><span></span>error[E0530]: let bindings cannot shadow tuple structs
 --&gt; src/lib.rs:5:17
  |
1 | struct foo();
  | ------------- a tuple struct `foo` is defined here
...
5 |     let Thing { foo } = t;
  |                 ^^^ cannot be named the same as a tuple struct
</pre></div>



<a name="137080719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/137080719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#137080719">(Nov 02 2018 at 20:34)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> that looks nice</p>



<a name="137086052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/destructuring%20grammar%20conflicts/near/137086052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/destructuring.20grammar.20conflicts.html#137086052">(Nov 02 2018 at 22:13)</a>:</h4>
<p>Filed <a href="https://github.com/rust-lang/rust/issues/55631" target="_blank" title="https://github.com/rust-lang/rust/issues/55631">https://github.com/rust-lang/rust/issues/55631</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>